package com.rem.hutool.my5Utils;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdcardUtil;

/**
 * 身份证校验
 *
 * @author Rem
 * @date 2020-08-24
 */

public class IdcardUtilDemo {

    public static void main(String[] args) {
        String iD18 = "321083197812162119";
        String iD15 = "150102880730303";

        //是否有效
        boolean valid = IdcardUtil.isValidCard(iD18);
        System.err.println(valid);
        boolean valid15 = IdcardUtil.isValidCard(iD15);
        System.err.println(valid15);

        //转换
        String convert15To18 = IdcardUtil.convert15To18(iD15);
        System.err.println(convert15To18);

        //年龄 现在年龄
        int ageByIdCard = IdcardUtil.getAgeByIdCard(iD18);
        System.err.println(ageByIdCard);

        //距离某个时间的年龄
        DateTime date = DateUtil.parse("2017-04-10");
        int age = IdcardUtil.getAgeByIdCard(iD18, date);
        System.err.println(age);

        //生日
        String birth = IdcardUtil.getBirthByIdCard(iD18);
        System.err.println(birth);

        String birth2 = IdcardUtil.getBirthByIdCard(iD15);
        System.err.println(birth2);

        //省份
        String province = IdcardUtil.getProvinceByIdCard(iD18);
        System.err.println(province);

        String province2 = IdcardUtil.getProvinceByIdCard(iD15);
        System.err.println(province2);


        boolean validCard18 = IdcardUtil.isValidCard("340825199503240218");
        System.err.println(validCard18);
    }
}
